
<html>

<head>
    <include file="public@head" title="编辑图片" keywords="后台管理系统"/>
</head>

<body class="layui-layout-admin">
<include file="public@header"/>
<include file="public@side"/>
<div class="layui-body">
    <div class="layui-breadcrumb" lay-filter="breadcrumb">
        <a href="{:url('tdadmin/index/index')}">主页</a>
        <a>系统设置</a>
        <a href="{:url('tdadmin/slide/index')}">相册管理</a>
        <a href="{:url('tdadmin/slide/items')}?slideID={$item.slide_id}">图片管理</a>
        <a><cite>编辑图片</cite></a>
    </div>

    <div class="layui-fluid">
        <div class="layui-card layui-col-md6">
            <div class="layui-card-header">
                编辑图片
            </div>
            <div class="layui-card-body">
                <form method="post" action="{:url('editItem')}" class="layui-form">
                    <div class="layui-form-item">
                        <label class="layui-form-label">标题<span class="form-required">*</span></label>
                        <div class="layui-input-block">
                            <input type="text" class="layui-input" name="slide[title]" value="{$item.title}"
                                   lay-verify="required" lay-verType="tips" placeholder="图片标题">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">链接<span class="form-required">*</span></label>
                        <div class="layui-input-block">
                            <input type="text" class="layui-input" name="slide[url]" value="{$item.url}"
                                   lay-verify="required|url" lay-verType="tips" placeholder="图片链接">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">图片<span class="form-required">*</span></label>
                        <div class="layui-input-block">
                            <a id="btn-thumb">
                                <empty name="item.thumb">
                                    <img src="__STATIC__/images/default-thumb.png" id="thumb-preview" height="135"
                                         style="cursor: pointer"/>
                                    <else/>
                                    <img src="{:get_image_url($item['thumb'])}" id="thumb-preview" height="135"
                                         style="cursor: pointer"/>
                                </empty>
                            </a>
                            <div id="tips-thumb"></div>
                            <input type="hidden" name="slide[thumb]" id="input-thumb" value="{$item.thumb}">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">描述</label>
                        <div class="layui-input-block">
                            <textarea class="layui-textarea" name="slide[desc]"
                                      placeholder="输入描述">{$item.desc}</textarea>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <div class="layui-input-block">
                            <input type="hidden" name="slide[slide_id]" value="{$item.slide_id}">
                            <input type="hidden" name="slide[id]" value="{$item.id}">
                            <button type="submit" class="layui-btn" lay-submit lay-filter="general">保存修改</button>
                            <a class="layui-btn layui-btn-primary" href="javascript:history.back(-1);">返回</a>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
<include file="public@scripts"/>
<script>
    var upload = layui.upload;

    upload.render({
        elem: '#btn-thumb',
        url: "{:url('api/asset/fileUpload')}",
        size: 20000,
        exts: 'jpg|png|bmp|jpeg',
        data: {path: 'slide'},
        before: function (obj) {
            obj.preview(function (index, file, result) {
                $('#thumb-preview').attr('src', result); //图片链接（base64）
            });
        },
        done: function (res) {
            if (res.code == 0) {
                return layer.msg(res.message);
            }
            $('#input-thumb').val(res.filepath);
        }
    });
</script>
</body>

</html>
